package fmanganiello.tests.javatests.depinj.creditcard.real;

import javax.naming.OperationNotSupportedException;

import fmanganiello.tests.javatests.depinj.billing.ChargeResult;
import fmanganiello.tests.javatests.depinj.creditcard.CreditCard;
import fmanganiello.tests.javatests.depinj.creditcard.CreditCardProcessor;

public abstract class RealCreditCardProcessor implements CreditCardProcessor {
	protected double additionalCost;
	protected ChargeResult result;
	
	public ChargeResult charge(CreditCard card, double amount) {
		try {
			card.charge(amount + additionalCost);
			return new ChargeResult();
		} catch (OperationNotSupportedException e) {
			return new ChargeResult(false, e.getMessage());
		}
	}
}
